package com.hunan.chinamobile.service.impl;

import com.hunan.chinamobile.dao.HUserMapper;
import com.hunan.chinamobile.dto.UserDTO;
import com.hunan.chinamobile.model.User;
import com.hunan.chinamobile.service.HUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HUserServiceImpl implements HUserService {

    @Autowired
    private HUserMapper hUserMapper;

    @Override
    public UserDTO login(String username, String password) {
        return hUserMapper.login(username, password);
    }

    @Override
    public User check(String username) {
        return hUserMapper.check(username);
    }

    @Override
    public List<User> findByCityId(String cityId) {
        return hUserMapper.findByCityId(cityId);
    }

    @Override
    public List<User> findByRoleAndUserName(String roleId,String name) {
        return hUserMapper.findByRoleAndUserName(roleId, name);
    }

    @Override
    public void save(User model) {
        hUserMapper.insert(model);
    }

    @Override
    public void deleteById(String id) {
        hUserMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(User model) {
        hUserMapper.updateByPrimaryKeySelective(model);
    }

    @Override
    public User findById(String id) {
        return hUserMapper.selectByPrimaryKey(id);
    }

    @Override
    public UserDTO findByUserName(String username) {
        return hUserMapper.findByUserName(username);
    }
}
